This enhanced analysis examines acid mine drainage (AMD) chemistry data from the Cerro Rico mining area collected during 2006-2007. The study provides comprehensive insights into seasonal variations in metal concentrations, pH levels, environmental risks, and associated impacts on water quality and ecosystem health.
Key Findings: - Extreme acidification with pH values ranging from 0.9 to 6.9 - Severe metal contamination exceeding regulatory standards by orders of magnitude - Significant seasonal variations in metal loading - Critical environmental risks requiring immediate intervention
Setup and Enhanced Configuration
Load Required Libraries
Code
# Core data manipulation and visualizationlibrary(tidyverse)library(readxl)library(janitor)library(patchwork)library(scales)library(DT)library(kableExtra)# Statistical analysislibrary(broom)library(corrplot)library(cluster)# Data quality and explorationlibrary(skimr)# Spatial and temporal analysislibrary(lubridate)# Advanced visualizationlibrary(RColorBrewer)library(viridis)library(ggridges)# File handlinglibrary(here)# Set global optionsoptions(scipen =999, digits =4)knitr::opts_chunk$set(fig.retina =2, dpi =300)
# Enhanced data loading with error handlingload_excel_robust <-function(file_path, sheet =NULL) {tryCatch({# Try different sheet optionsif (is.null(sheet)) { sheets <-excel_sheets(file_path)if (length(sheets) >1) {cat("Multiple sheets found:", paste(sheets, collapse =", "), "\n") sheet <- sheets[1] # Use first sheet } } data <-read_excel(file_path, sheet = sheet) %>%clean_names()cat("✓ Loaded", file_path, "with", nrow(data), "rows and", ncol(data), "columns\n")return(data) }, error =function(e) {warning(paste("Failed to load", file_path, ":", e$message))return(NULL) })}# Load real data if availableif (length(metal_files) >0&&length(phys_files) >0) {# Load metal data metals_list <-map(metal_files, load_excel_robust) metals_list <- metals_list[!map_lgl(metals_list, is.null)]if (length(metals_list) >0) { metals_raw <-bind_rows(metals_list, .id ="file_id") } else { metals_raw <-NULL }# Load physical data phys_list <-map(phys_files, load_excel_robust) phys_list <- phys_list[!map_lgl(phys_list, is.null)]if (length(phys_list) >0) { phys_raw <-bind_rows(phys_list, .id ="file_id") } else { phys_raw <-NULL }# Combine if both existif (!is.null(metals_raw) &&!is.null(phys_raw)) {# Clean individual datasets metals <-clean_amd_data(metals_raw, "metals") phys <-clean_amd_data(phys_raw, "physical")# Identify common columns for joining common_cols <-intersect(names(metals), names(phys)) join_cols <-intersect(c("site", "season", "n", "sample_id", "date"), common_cols)if (length(join_cols) >0) { amd_raw <-full_join(metals, phys, by = join_cols, suffix =c("_metal", "_phys"))cat("✓ Joined datasets on:", paste(join_cols, collapse =", "), "\n") } else {cat("⚠ No common columns found for joining. Combining by row binding.\n") amd_raw <-bind_rows(metals, phys) } } else { amd_raw <-NULL }} else { amd_raw <-NULL}
✓ Loaded /Users/ktdroppa/Desktop/riverremedy/data/raw/Strosnider_2011_metal_data_dry_2006.xlsx with 12 rows and 15 columns
✓ Loaded /Users/ktdroppa/Desktop/riverremedy/data/raw/Strosnider_2011_metal_data_wet_2007.xlsx with 16 rows and 15 columns
✓ Loaded /Users/ktdroppa/Desktop/riverremedy/data/raw/Strosnider_2011_physical_data_all.xlsx with 28 rows and 10 columns
✓ Loaded /Users/ktdroppa/Desktop/riverremedy/data/raw/Strosnider_2011_physical_data_dry_2006.xlsx with 12 rows and 10 columns
✓ Loaded /Users/ktdroppa/Desktop/riverremedy/data/raw/Strosnider_2011_physical_data_wet_2007.xlsx with 16 rows and 10 columns
✓ Enhanced cleaning of metals :
Rows: 28 → 28
Columns: 16 → 20
Missing data: 0 % → 0 %
✓ Enhanced cleaning of physical :
Rows: 56 → 56
Columns: 11 → 17
Missing data: 3.2 % → 6.2 %
✓ Joined datasets on: site, season, n
Code
# Create enhanced sample data based on actual Strosnider et al. (2011) findingsif (is.null(amd_raw)) {cat("⚠ No data files found. Creating sample dataset based on Strosnider et al. (2011) findings.\n")set.seed(42)# Based on Table 1 and 2 from the paper - actual AMD discharge sites site_codes <-c("1C", "2C", "3C", "4C", "5C", "6C", "7C", "1A", "2A", "3A", "4A", "5A", "1T", "2T", "3T", "4T")# Create samples for both dry and wet seasons as in the paper n_samples <-length(site_codes) *2# dry and wet season# Generate realistic data based on actual measurements in Tables 1-2 amd_raw <-tibble(site =rep(site_codes, 2),season =rep(c("dry", "wet"), each =length(site_codes)),# pH values based on Table 1 (range 0.9-6.9)p_h =case_when( site %in%c("1C", "2C", "3C", "4C", "5C", "6C") ~runif(n_samples, 2.5, 3.6), site =="7C"~ifelse(season =="wet", 2.1, NA), site %in%c("1A", "2A", "3A") ~runif(n_samples, 2.9, 4.5), site %in%c("4A", "5A") ~runif(n_samples, 6.8, 6.9), site %in%c("1T", "2T") ~runif(n_samples, 3.0, 4.2), site =="3T"~runif(n_samples, 6.4, 6.5), site =="4T"~0.9, # Most extreme case from paperTRUE~runif(n_samples, 3.0, 4.0) ),# Temperature (reasonable range for Potosí elevation ~4000m)temp_c =rnorm(n_samples, 12, 3),# Specific conductance based on Table 1 (μS/cm)cond_s_cm =case_when( site =="4T"~54600, # Extreme case site %in%c("4A", "5A", "3T") ~runif(n_samples, 272, 960), site %in%c("1T", "2T") ~runif(n_samples, 1115, 2820),TRUE~runif(n_samples, 3000, 23000) ),# Flow rates based on Table 1 (L/s)q_l_s =case_when( season =="wet"~abs(rnorm(n_samples, 0.3, 0.4)),TRUE~abs(rnorm(n_samples, 0.1, 0.2)) ),# Metal concentrations based on Table 2 ranges (mg/L)# Iron: 0.12 to 72,100 mg/Lfe =case_when( site =="4T"~ifelse(season =="wet", 72100, 70500), # Extreme Pailaviri tailings site %in%c("4A", "5A") ~runif(n_samples, 0.12, 3.12), site %in%c("2T", "3T") ~runif(n_samples, 0.14, 0.36),TRUE~runif(n_samples, 100, 8130) ),# Aluminum: 0.11 to 7,480 mg/Lal =case_when( site =="4T"~7480, # Most extreme site %in%c("4A", "5A") ~runif(n_samples, 0.11, 3.82),TRUE~runif(n_samples, 5, 1300) ),# Zinc: 0.24 to 19,600 mg/L zn =case_when( site =="4T"~ifelse(season =="wet", 1660, 19600), site %in%c("4A", "5A") ~runif(n_samples, 0.24, 0.26),TRUE~runif(n_samples, 100, 10500) ),# Manganese: 0.3 to 402 mg/Lmn =case_when( site =="4T"~runif(n_samples, 91, 96), site %in%c("4A", "5A") ~runif(n_samples, 0.3, 4.0),TRUE~runif(n_samples, 9, 402) ),# Copper: <0.001 to 310 mg/Lcu =case_when( site =="4T"~310, # Extreme case site %in%c("4A", "5A") ~runif(n_samples, 0.001, 0.002),TRUE~runif(n_samples, 0.1, 227) ),# Lead: <0.012 to 34.8 mg/Lpb =case_when( site =="4T"~runif(n_samples, 24, 26), site %in%c("4A", "5A") ~runif(n_samples, 0.012, 0.043),TRUE~runif(n_samples, 0.05, 34.8) ),# Cadmium: <0.0006 to 65.3 mg/Lcd =case_when( site =="4T"~runif(n_samples, 15, 17), site %in%c("4A", "5A") ~runif(n_samples, 0.0006, 0.001),TRUE~runif(n_samples, 0.1, 65.3) ),# Arsenic: <0.022 to 889 mg/Las =case_when( site =="4T"~889, # Extreme case site %in%c("4A", "5A", "1T", "2T", "3T") ~0.022, # Below detectionTRUE~runif(n_samples, 0.5, 180) ),# Additional metalscr =case_when( site =="4T"~runif(n_samples, 2.5, 2.6),TRUE~runif(n_samples, 0.001, 1.1) ),ni =case_when( site =="4T"~runif(n_samples, 11, 12),TRUE~runif(n_samples, 0.004, 6.0) ),# Net acidity (mg/L as CaCO3 equivalent) - based on Table 1net_acidity =case_when( site =="4T"~runif(n_samples, 181000, 246000), # Extreme site %in%c("4A", "5A", "3T") ~runif(n_samples, -46, -6), # Negative (alkaline)TRUE~runif(n_samples, 1000, 53500) ),# Sulfate concentrationsso4 =case_when( site =="4T"~175000, # Extreme site %in%c("4A", "5A") ~runif(n_samples, 232, 257),TRUE~runif(n_samples, 500, 34000) ) ) %>%# Remove NA values and add datesfilter(!is.na(p_h)) %>%mutate(date =case_when( season =="dry"~as.Date("2006-08-01"), # July-August 2006 season =="wet"~as.Date("2007-03-15") # March 2007 ),# Add sample quality indicators based on site characteristicssample_quality =case_when( site %in%c("4A", "5A", "3T") ~"high", # Near-neutral pH sites site =="4T"~"extreme", # Most contaminated site %in%c("1A", "2A", "3A") ~"poor", # Abandoned portalsTRUE~"low"# Active portals ),# Add some realistic missing data patterns (5% missing for trace metals)across(c(cd, cr, ni, as), ~ifelse(runif(n()) <0.05, NA, .x)) )cat("✓ Created sample dataset based on Strosnider et al. (2011) with", nrow(amd_raw), "samples\n")cat(" Sites included:", paste(unique(amd_raw$site), collapse =", "), "\n")cat(" pH range:", round(min(amd_raw$p_h, na.rm =TRUE), 1), "to", round(max(amd_raw$p_h, na.rm =TRUE), 1), "\n")cat(" Most extreme site (4T - Pailaviri tailings): pH =", round(min(amd_raw$p_h[amd_raw$site =="4T"], na.rm =TRUE), 1), "\n")}# Final cleaning and enhancementamd <-clean_amd_data(amd_raw, "combined AMD")
# Identify available columnsavailable_metals <-detect_metal_columns(amd)
✓ Detected 12 metal columns:
# A tibble: 12 × 4
column metal confidence priority
<chr> <chr> <dbl> <dbl>
1 al al 1 1
2 as as 1 1
3 cd cd 1 1
4 cr cr 1 1
5 cu cu 1 1
6 fe fe 1 1
7 mn mn 1 1
8 pb pb 1 1
9 zn zn 1 1
10 co co 1 2
11 ni ni 1 2
12 q_l_s s 0.8 2
cat("• Quality Assurance: Implement duplicate sampling and certified reference materials\n")
• Quality Assurance: Implement duplicate sampling and certified reference materials
Code
# Data quality recommendationscat("\nDATA QUALITY RECOMMENDATIONS\n")
DATA QUALITY RECOMMENDATIONS
Code
cat("=============================\n")
=============================
Code
cat("• Standardize sampling protocols across all sites\n")
• Standardize sampling protocols across all sites
Code
cat("• Implement quality control measures (blanks, duplicates, spikes)\n")
• Implement quality control measures (blanks, duplicates, spikes)
Code
cat("• Use certified reference materials for method validation\n")
• Use certified reference materials for method validation
Code
cat("• Document metadata for all samples (weather, flow conditions, etc.)\n")
• Document metadata for all samples (weather, flow conditions, etc.)
Code
cat("\n=== ENHANCED ANALYSIS COMPLETE ===\n")
=== ENHANCED ANALYSIS COMPLETE ===
Conclusions
This enhanced analysis reproduces and extends the findings of Strosnider et al. (2011) on acid mine drainage at Cerro Rico de Potosí, revealing the extent of environmental contamination from five centuries of mining operations.
Key Findings from Strosnider et al. (2011):
Extreme Metal Concentrations: - Iron: 0.12 to 72,100 mg/L (Pailaviri tailings seep - site 4T) - Aluminum: 0.11 to 7,480 mg/L - Zinc: 0.24 to 19,600 mg/L - Arsenic: <0.022 to 889 mg/L - Copper: <0.001 to 310 mg/L - Lead: <0.012 to 34.8 mg/L - Cadmium: <0.0006 to 65.3 mg/L - Manganese: 0.3 to 402 mg/L
Extreme Acidification: - pH range: 0.90 to 6.94 standard units - Net acidity: -10 to 246,000 mg/L as CaCO₃ equivalent - Most extreme case: Pailaviri tailings seep (site 4T) with pH = 0.9
Regulatory Violations: - All but one AMD discharge exceeded Bolivian monthly discharge limits - Most exceeded by orders of magnitude for multiple metals - Fourteen discharges had impermissible Zn concentrations (often 3-4 orders of magnitude above limits) - Thirteen discharges violated pH requirements
Historical Impact:
The study demonstrates that if observed loadings are historically representative, Cerro Rico AMD has contributed thousands of tonnes of ecotoxic metals to the upper Rio Pilcomayo over the last five centuries.
Site-Specific Findings:
Most Contaminated Sources: 1. Pailaviri tailings seep (4T): Most extreme concentrations, rivaling Iron Mountain (California) 2. Active mine portals (1C-7C): Generally higher concentrations than abandoned portals 3. Abandoned portals (1A-5A): Connected to active workings, showing ongoing contamination
Seasonal Patterns: - Wet season: Marginally greater loadings for most metals (Al +26%, As +12%, Fe +88%, Mn +76%, Ni +45%, Pb +57%) - Flow increases during wet season mobilize more contaminants
Environmental Significance:
Downstream Contamination: - AMD contributes to violations of Class D receiving water standards (lowest classification - industrial use only) - Metal concentrations orders of magnitude above background levels documented 500+ km downstream - Isotopic studies confirm mining sources of contamination
Ecological Impact: - Concentrations exceed aquatic life criteria by orders of magnitude - Historic precedent: Agricola (1556) noted that mine drainage “destroys the fish or drives them away”
Technical Recommendations:
Immediate Actions: 1. Emergency treatment for critical sites (especially 4T - Pailaviri tailings) 2. Source control measures at active operations 3. Real-time monitoring networks
Treatment Approach: - Passive treatment systems recommended due to economic constraints - Locally available materials: limestone and organic substrates (llama dung, cattle manure, brewery waste) - Hybrid active-passive systems for extreme cases - Co-treatment with municipal wastewater shows promise
Long-term Strategy: 1. Comprehensive watershed restoration 2. Enforcement of environmental regulations (Law 1333) 3. Sustainable mining practices 4. Community health monitoring
Regulatory Context:
Despite Bolivia’s environmental law Number 1333 (1992) establishing discharge limits, Garcia-Guinea and Harffy (1998) observed that “Bolivian environmental law has been sadly ignored where mining is concerned.” This study provides the first quantitative documentation of the extent of this non-compliance.
Research Contributions:
This analysis provides: - First peer-reviewed characterization of Cerro Rico AMD sources - Quantitative link between upstream sources and downstream contamination - Baseline data for future remediation efforts - Framework for assessing mining impacts in similar settings
The findings underscore the urgent need for environmental intervention while considering the economic realities of one of the Western Hemisphere’s poorest regions, where approximately 150,000 residents depend on mining-related activities for their livelihoods.